/**
 * 添加水文模型数据（tif数据源）
 * @param api
 * @param dPath 水深文件地址 D:/water/H71-2.TIF
 * @param uvPath UV文件地址 D:/water/UV71-2.tif
 * @param demPath 地形文件地址 D:/water/E-2.TIF
 * @param focus 是否自动定位要模型位置
 */
export function addWaterModel(api: any, dPath: string, uvPath: string, demPath: string, focus = false) {
  api.hydrodynamic2d.clear();
  api.hydrodynamic2d.addByTif({
    id: 'hdm',
    offset: [0, 0, 0],
    displayMode: 1,
    waterMode: 1,
    collision: true, //开启碰撞
    waveBrightness: 10,
    alphaMode: 0,
    arrowColor: [1, 0.5, 0, 0.8],
    arrowTiling: 2,
    rippleDensity: 1,
    rippleTiling: 1,
    speedFactor: 1,
    foamWidth: 1,
    foamIntensity: 0.5,
    alphaComposite: true,
    waterDepth: dPath,
    flowField: uvPath,
    dem: demPath,
    colors: {
      gradient: true,
      invalidColor: [0, 0, 0, 1],
      colorStops: [
        { value: 0, color: [0, 1, 0, 0] },
        { value: 0.5, color: [0.2196, 0.6549, 0, 1] },
        { value: 1, color: [0.4314, 0.7608, 0.0118, 1] },
        { value: 3, color: [0.6902, 0.8784, 0.0039, 1] },
        { value: 5, color: [1, 1, 0, 1] },
        { value: 7, color: [1, 0.3333, 0, 1] },
        { value: 9, color: [1, 0, 0, 1] },
      ],
    },
  });
  focus && api.hydrodynamic2d.focus('hdm', 1000);
}
